package com.example.sports_meet.subject;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.sports_meet.R;
import com.example.sports_meet.adapter.OptionAdapter;
import com.example.sports_meet.entity.Option;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class Subject_mainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_subject_main);
        Objects.requireNonNull(getSupportActionBar()).hide();
        ListView lv_choose = findViewById(R.id.lv_manager);
        List<Option> options = new ArrayList<>();
        options.add(new Option("录入项目信息", subject_add.class));
        options.add(new Option("删除项目信息", subject_del.class));
        options.add(new Option("更改项目信息", subject_mod.class));
        options.add(new Option("查询项目信息", subject_que.class));


        OptionAdapter adapter = new OptionAdapter(this, options);
        lv_choose.setAdapter(adapter);
        lv_choose.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position) {
                    case 0:
                        // 点击第一个选项，跳转到Activity1
                        startActivity(new Intent(Subject_mainActivity.this, subject_add.class));
                        break;
                    case 1:
                        // 点击第二个选项，跳转到Activity2
                        startActivity(new Intent(Subject_mainActivity.this, subject_del.class));
                        break;
                    case 2:
                        startActivity(new Intent(Subject_mainActivity.this, subject_mod.class));
                        break;
                    case 3:
                        startActivity(new Intent(Subject_mainActivity.this, subject_que.class));
                        break;
                }
            }
        });
    }
}